package com.qfedu.mapper;

import com.qfedu.model.Contractor;
import com.qfedu.model.Developer;
import com.qfedu.model.Branch;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @author LiJH
 * @date 2023-02-10
 */
public interface BranchMapper {
    @Select("select count(*) from branch where status=1")
    long count();
    @Select("select * from branch where status=1 limit #{currentPage},#{pageSize}")
    List<Branch> findPage(@Param("currentPage") Integer currentPage, @Param("pageSize") Integer pageSize);

    @Insert("insert into branch(bid,bname,pid,updatetime) values(#{bid},#{bname},#{pid},#{updatetime}) ")
    int addBranch(Branch branch);

    @Select("select * from branch where bid=#{bid} and status=1 ")
    Branch findById(String bid);

    @Select("select * from branch where pid=#{pid} and status=1 ")
    List<Branch> findByPid(int pid);

    @Update("update branch set bname=#{bname},pid=#{pid},starttime=#{starttime} where bid=#{bid}")
    int editBranch(Branch branch);

    //删除
    @Update("update branch set status=0 where bid = #{bid}")
    int deleteByPid(String bid);
}